package com.woniuxy.stage3demo.mapper.lyl;

import com.woniuxy.stage3demo.bean.lyl.StationMessageBean;
import com.woniuxy.stage3demo.pageHelper.PageRequest;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;
@Mapper
public interface StationMessageMapper {
    /**
     * 分页查询
     * @param
     * @return
     */
   /* @Results({
            @Result(id=true,property = "id",column = "id",javaType = Integer.class),
            @Result(property = "stationMsgNo",column = "station_msg_no",javaType = String.class),
            @Result(property = "stationMsgTitle",column = "station_msg_titel",javaType = String.class),
            @Result(property = "stationMsgContent",column = "station_msg_content",javaType = String.class),
            @Result(property = "createTime",column = "create_time",javaType = Date.class),
            @Result(property = "delFlag",column = "del_flag",javaType = Integer.class),
            @Result(property = "staff",column = "staff_id",javaType = StaffBean.class,one =
            @One(select = "com.woniuxy.stage3demo.mapper.lyl.StaffMapper.getOneById",fetchType = FetchType.LAZY))
    })

    @Select("select * from station_msg where staffId=0")*/
     List<StationMessageBean> findAllByParams(@Param("p") PageRequest request,@Param("s")StationMessageBean stationMessageBean);
    /**
     * 存储新消息
     * @param stationMessageBean
     */
    @Insert("insert into station_msg (station_msg_no,station_msg_titel,station_msg_content,create_time,staff_id,del_flag) values" +
            "(#{s.stationMsgNo},#{s.stationMsgTitle},#{s.stationMsgContent},#{s.createTime},#{s.staffBean.id},1)")
    void saveStationMessageBean(@Param("s") StationMessageBean stationMessageBean);
    /**
     * 删除站内信
     * @param id 站内信id
     */
    @Update("update station_msg set del_flag = 0 where id=#{id}")
    void deleteOneStationMessageBean(@Param("id")Long id);
    /**
     * 条件查询站内信
     * @param stationMsgTitle
     * @param
     */
    /*@Results({
            @Result(id=true,property = "id",column = "id",javaType = Integer.class),
            @Result(property = "stationMsgNo",column = "station_msg_no",javaType = String.class),
            @Result(property = "stationMsgTitle",column = "station_msg_titel",javaType = String.class),
            @Result(property = "stationMsgContent",column = "station_msg_content",javaType = String.class),
            @Result(property = "createTime",column = "create_time",javaType = Date.class),
            @Result(property = "delFlag",column = "del_flag",javaType = Integer.class),
            @Result(property = "staff",column = "staff_id",javaType = StaffBean.class,one =
            @One(select = "com.woniuxy.stage3demo.mapper.lyl.StaffMapper.getOneById",fetchType = FetchType.LAZY))
    })
@Select("<script>" +
        "select s.id,s.station_msg_no,s.station_msg_title,s.station_msg_content,s.create_time,s.staff_id,s.del_flag from station_msg as s ,staff where " +
        "<if test='stationMsgTitle!=null'>" +
        "s.station_msg_title=#{stationMsgTitle}," +
        "</if>" +
        "<if test='name!=null'>" +
        "staff.name=#{name}," +
        "</if>" +
        "and del_flag=0"+
        "</script>")
    List<StationMessageBean> selectStationMessageBeanByTitleAndName(PageRequest request,String stationMsgTitle,String name );
*/
}
